
package ui.adapter;

import android.content.Context;
import android.support.v7.widget.DefaultItemAnimator;
import android.support.v7.widget.LinearLayoutManager;

import net.ck.hzq.R;

import java.util.ArrayList;
import java.util.List;

import base.BaseViewHolder;
import base.SuperBaseAdapter;
import cn.finalteam.loadingviewfinal.RecyclerViewFinal;
import dao.TradeRecordItem;


/**
 * 交易明细主适配器
 * Created by chenjian on 19/2/27.
 */
public class TradeRecordAdapter extends SuperBaseAdapter<TradeRecordItem> {

    List<TradeRecordItem> mData = new ArrayList<>();
    Context mContext;

    public TradeRecordAdapter(Context context, List<TradeRecordItem> data) {
        super(context, data);
        mContext = context;
        mData = data;
    }

    @Override
    protected void convert(BaseViewHolder holder, final TradeRecordItem item, final int position) {
        holder.setText(R.id.month, item.getMonth());
        RecyclerViewFinal rv = holder.getView(R.id.refresh_rv);
        rv.setLayoutManager(new LinearLayoutManager(mContext));
        rv.setItemAnimator(new DefaultItemAnimator());
        TradeRecordChildAdapter adapter = new TradeRecordChildAdapter(mContext, item.getMerchants(), item.getMonth());
        rv.setAdapter(adapter);
    }


    @Override
    protected int getItemViewLayoutId(int position, TradeRecordItem item) {
        return R.layout.item_trade_record_month;
    }

}
